<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="<%=request.getContextPath()%>/">
    <meta charset="UTF-8">
    <title>编辑预约</title>
    <link rel="stylesheet" href="statics/css/newsStyle.css">
</head>
<body>
<%@include file="../common/sidebar.jsp"%>
<div class="main-content">
    <%@include file="../common/top.jsp"%>
    <div class="content">
        <div class="card">
            <h2 class="section-title">编辑预约</h2>
            <form action="appointment/modify" method="post">
                <!-- 隐藏域传递预约ID -->
                <input type="hidden" name="appointmentId" value="${appointment.appointmentId}"/>
                <div class="form-group">
                    <label>患者姓名：</label>
                    <input type="text" name="patientName" value="${appointment.patientName}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label>联系电话：</label>
                    <input type="text" name="patientPhone" value="${appointment.patientPhone}" class="form-control" required>
                </div>
                <div class="form-group">
                    <label>选择排班：</label>
                    <select name="visitId" class="form-control" required>
                        <option value="">-- 请选择排班 --</option>
                        <c:forEach items="${availableVisits}" var="visit">
                            <option value="${visit.visitId}" 
                                    <c:if test="${appointment.visitId eq visit.visitId}">selected</c:if>>
                                    ${visit.department.deptName} - ${visit.doctorName} - ${visit.visitDate} ${visit.timeSlot}
                            </option>
                        </c:forEach>
                    </select>
                </div>
                <div class="form-group">
                    <label>病情描述：</label>
                    <textarea name="symptoms" class="form-control" rows="3">${appointment.symptoms}</textarea>
                </div>
                <div class="form-group">
                    <label>预约状态：</label>
                    <select name="status" class="form-control">
                        <option value="0" <c:if test="${appointment.status eq 0}">selected</c:if>>待就诊</option>
                        <option value="1" <c:if test="${appointment.status eq 1}">selected</c:if>>已确认</option>
                        <option value="2" <c:if test="${appointment.status eq 2}">selected</c:if>>已完成</option>
                        <option value="3" <c:if test="${appointment.status eq 3}">selected</c:if>>已取消</option>
                    </select>
                </div>
                <div class="form-actions">
                    <button type="submit" class="btn btn-primary">保存修改</button>
                    <a href="appointment/find" class="btn btn-default">取消</a>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>